package com.example.medioplayer.fragment;


import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.medioplayer.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class Test3 extends Fragment {
    SwipeRefreshLayout ft_srl;
    TextView textView1;

    public Test3() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view= inflater.inflate(R.layout.fragment_test3, container, false);
        ft_srl= (SwipeRefreshLayout) view.findViewById(R.id.ft_srl);
        textView1= (TextView) view.findViewById(R.id.textView1);
        ft_srl.setColorSchemeResources(android.R.color.holo_blue_light,android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
        ft_srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                textView1.setVisibility(View.VISIBLE);
                textView1.setText("正在刷新");
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        textView1.setText("刷新完成");
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                textView1.setVisibility(View.GONE);
                            }
                        },1000);

                        ft_srl.setRefreshing(false);
                    }
                },2000);
            }
        });
        return view;
    }

}
